import { Tree } from "./Tree"
const tree1: Tree = {
  val: 'a',
  children: [
    {
      val: 'b',
      children: [
        {
          val: 'd',
          children: []
        },
        {
          val: 'e',
          children: []
        },
      ]
    },
    {
      val: 'c',
      children: [
        {
          val: 'f',
          children: []
        },
        {
          val: 'g',
          children: []
        },
      ]
    }
  ]
}

/**
 * 深度优先遍历
 * @param root 根元素
 */
const dfs = (root: Tree) => {
  console.log(root.val)
  root.children.forEach(item => dfs(item))
}

dfs(tree1)